From 72a9bb3cfb4031290eafc99f0c220d9dd8eb9eb3 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 10 May 2007 22:54:43 +0100 Subject: [PATCH] xen: Some cleanups for x86 start of day. 1. Remove erroneous modification to e820.c 2. Make sure Xen is relocated as high as possible below 4GB. Signed-off-by: Keir Fraser --- xen/arch/x86/e820.c | 2 +- xen/arch/x86/setup.c | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 72267a71e8..95daf54302 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -32,7 +32,7 @@ static void __init add_memory_region(unsigned long long start, } } /* add_memory_region */ -/*static*/ void __init print_e820_memory_map(struct e820entry *map, int entries) +static void __init print_e820_memory_map(struct e820entry *map, int entries) { int i; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 795dcc9478..ea90e800e0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -462,7 +462,7 @@ void __init __start_xen(multiboot_info_t *mbi) } /* - * Iterate over all superpage-aligned RAM regions. + * Iterate backwards over all superpage-aligned RAM regions. * * We require superpage alignment because the boot allocator is not yet * initialised. Hence we can only map superpages in the address range @@ -475,7 +475,7 @@ void __init __start_xen(multiboot_info_t *mbi) * x86/64, we relocate Xen to higher memory. */ modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start; - for ( i = 0; i < boot_e820.nr_map; i++ ) + for ( i = boot_e820.nr_map-1; i >= 0; i-- ) { uint64_t s, e, mask = (1UL << L2_PAGETABLE_SHIFT) - 1; @@ -491,19 +491,6 @@ void __init __start_xen(multiboot_info_t *mbi) (unsigned long)maddr_to_bootstrap_virt(s), s >> PAGE_SHIFT, (e-s) >> PAGE_SHIFT, PAGE_HYPERVISOR); - /* Is the region suitable for relocating the multiboot modules? */ - if ( !initial_images_start && ((e-s) >= modules_length) ) - { - e -= modules_length; - e &= ~mask; - initial_images_start = e; - initial_images_end = initial_images_start + modules_length; - move_memory(initial_images_start, - mod[0].mod_start, mod[mbi->mods_count-1].mod_end); - if ( s >= e ) - continue; - } - #if defined(CONFIG_X86_64) /* Is the region suitable for relocating Xen? */ if ( !xen_phys_start && (((e-s) >> 20) >= opt_xenheap_megabytes) ) @@ -571,6 +558,16 @@ void __init __start_xen(multiboot_info_t *mbi) "D" (__va(__pa(cpu0_stack))), "c" (STACK_SIZE) : "memory" ); } #endif + + /* Is the region suitable for relocating the multiboot modules? */ + if ( !initial_images_start && (s < e) && ((e-s) >= modules_length) ) + { + e -= modules_length; + initial_images_start = e; + initial_images_end = initial_images_start + modules_length; + move_memory(initial_images_start, + mod[0].mod_start, mod[mbi->mods_count-1].mod_end); + } } if ( !initial_images_start ) -- 2.30.2